/*统一管理项目用户相关的接口*/
import request from '@/utils/request'
import {
  loginFromData,
  userInfoResponseData,
  logoutResponseData,
  reqCode,
} from '@/api/user/type'

/*项目用户相关的请求地址*/
enum API {
  LOGIN_URL = '/login',
  USER_INFO_URL = '/getInfo',
  LOGOUT_URL = '/logout',
  GETROUTER_URL = '/getRouters',
  LOGIN_CODE_URL = '/captcha' /*获取验证码*/,
}

/*登录*/
export const reqLogin = (data: any) =>
  request.post<loginFromData, loginFromData>(
    API.LOGIN_URL,
    data,
  ) /*提交的是表单信息*/

/*获取用户信息*/
export const reqUserInfoUrl = () =>
  request.get<any, userInfoResponseData>(API.USER_INFO_URL)

/*退出登录*/
export const reqLogout = () => {
  return request.post<any, logoutResponseData>(API.LOGOUT_URL)
}

/*获取路由*/
export const reqGetRouter = () => {
  return request.get<any, any>(API.GETROUTER_URL)
}

/**
 * 获取验证码
 */
export const reqCodeUrl = () => {
  return request.get<any, reqCode>(API.LOGIN_CODE_URL)
}
